package player;


import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;

import org.omg.CORBA.ORB;
import org.omg.CORBA.StringHolder;

import common.CommonTools;

import player.playerService;
import player.playerServiceHelper;


public class PlayerClientTest {

	public static void main(String[] args) {
		try {
			String clientIPAddressEU = CommonTools.getproperty(
					"client.properties", "clientIPAddressEU");
			String clientIPAddressNA = CommonTools.getproperty(
					"client.properties", "clientIPAddressNA");
			String clientIPAddressAS = CommonTools.getproperty(
					"client.properties", "clientIPAddressAS");
			//-------------------------------------------------------------------------------
			ORB orbEU = ORB.init(args, null);
			ORB orbAS = ORB.init(args, null);
			ORB orbNA = ORB.init(args, null);
			
			String playerIOR_EU = CommonTools.getIOR("player", "EU","client");
			String playerIOR_AS = CommonTools.getIOR("player", "AS","client");
			String playerIOR_NA = CommonTools.getIOR("player", "NA","client");
	
			org.omg.CORBA.Object playerServiceObjectEU = orbEU.string_to_object(playerIOR_EU);
			org.omg.CORBA.Object playerServiceObjectAS = orbAS.string_to_object(playerIOR_AS);
			org.omg.CORBA.Object playerServiceObjectNA = orbNA.string_to_object(playerIOR_NA);
			
			playerService playerServiceEU = playerServiceHelper.narrow(playerServiceObjectEU);
			playerService playerServiceAS = playerServiceHelper.narrow(playerServiceObjectAS);
			playerService playerServiceNA = playerServiceHelper.narrow(playerServiceObjectNA);
			
			
			PlayerClient playerClientEU = new PlayerClient(playerServiceEU);
			PlayerClient playerClientNA = new PlayerClient(playerServiceNA);
			PlayerClient playerClientAS = new PlayerClient(playerServiceAS);
			
		/*	//8 Creation in EU server
			new Thread(new PlayerClientCreateThread(playerClientEU, "Bill", "Clinton", 68, "ClintonEU",
					"bcbc1234", clientIPAddressEU)).start();
			new Thread(new PlayerClientCreateThread(playerClientEU, "George", "Bush", 68, "BushEU", "gbgb1234",
					clientIPAddressEU)).start();
			new Thread(new PlayerClientCreateThread(playerClientEU, "Jinping", "Xi", 61, "Xi", "jxjx1234",
					clientIPAddressEU)).start();
			new Thread(new PlayerClientCreateThread(playerClientEU, "Shinzo", "Abe", 60, "Abe", "sasa1234",
					clientIPAddressEU)).start();
			new Thread(new PlayerClientCreateThread(playerClientEU, "Francois", "Hollande", 60, "Hollande",
					"fhfh1234", clientIPAddressEU)).start();
			new Thread(new PlayerClientCreateThread(playerClientEU, "Angela", "Merkel", 60, "Merkel",
					"amam1234", clientIPAddressEU)).start();
			new Thread(new PlayerClientCreateThread(playerClientEU, "Francois", "Hollande", 60, "Hollande1",
					"fhfh1234", clientIPAddressEU)).start();
			new Thread(new PlayerClientCreateThread(playerClientEU, "Angela", "Merkel", 60, "Merkel1",
					"amam1234", clientIPAddressEU)).start();
			
			//6 Creation in NA server
			new Thread(new PlayerClientCreateThread(playerClientNA, "Bill", "Clinton", 68, "ClintonNA",
					"bcbc1234", clientIPAddressNA)).start();
			new Thread(new PlayerClientCreateThread(playerClientNA, "George", "Bush", 68, "BushNA", "gbgb1234",
					clientIPAddressNA)).start();
			new Thread(new PlayerClientCreateThread(playerClientNA, "Jinping", "Xi", 61, "Xi", "jxjx1234",
					clientIPAddressNA)).start();
			new Thread(new PlayerClientCreateThread(playerClientNA, "Shinzo", "Abe", 60, "Abe", "sasa1234",
					clientIPAddressNA)).start();
			new Thread(new PlayerClientCreateThread(playerClientNA, "Francois", "Hollande", 60, "Hollande",
					"fhfh1234", clientIPAddressNA)).start();
			new Thread(new PlayerClientCreateThread(playerClientNA, "Angela", "Merkel", 60, "Merkel",
					"amam1234", clientIPAddressNA)).start();
			//6 Creation in AS server
			new Thread(new PlayerClientCreateThread(playerClientAS, "Bill", "ClintonAS", 68, "ClintonAS",
					"bcbc1234", clientIPAddressAS)).start();
			new Thread(new PlayerClientCreateThread(playerClientAS, "George", "BushAS", 68, "BushAS", "gbgb1234",
					clientIPAddressAS)).start();
			new Thread(new PlayerClientCreateThread(playerClientAS, "Jinping", "Xi", 61, "Xi", "jxjx1234",
					clientIPAddressAS)).start();
			new Thread(new PlayerClientCreateThread(playerClientAS, "Shinzo", "Abe", 60, "Abe", "sasa1234",
					clientIPAddressAS)).start();
			new Thread(new PlayerClientCreateThread(playerClientAS, "Francois", "Hollande", 60, "Hollande",
					"fhfh1234", clientIPAddressAS)).start();
			new Thread(new PlayerClientCreateThread(playerClientAS, "Angela", "Merkel", 60, "Merkel",
					"amam1234", clientIPAddressAS)).start();
			
			// sign in for EU server
			new Thread(new PlayerClientSignInThread(playerClientEU, "Clinton", "bcbc1234", clientIPAddressEU)).start();
			new Thread(new PlayerClientSignInThread(playerClientEU, "Bush", "gbgb1234", clientIPAddressEU)).start();
			new Thread(new PlayerClientSignInThread(playerClientEU, "Xi", "jxjx1234", clientIPAddressEU)).start();
			new Thread(new PlayerClientSignInThread(playerClientEU, "Merkel", "amam1234", clientIPAddressEU)).start();
			new Thread(new PlayerClientSignInThread(playerClientEU, "Hollande", "fhfh1234", clientIPAddressEU)).start();
			
			//sign in for NA server
			new Thread(new PlayerClientSignInThread(playerClientNA, "Clinton", "bcbc1234", clientIPAddressNA)).start();
			new Thread(new PlayerClientSignInThread(playerClientNA, "Bush", "gbgb1234", clientIPAddressNA)).start();
			new Thread(new PlayerClientSignInThread(playerClientNA, "Xi", "jxjx1234", clientIPAddressNA)).start();
			new Thread(new PlayerClientSignInThread(playerClientNA, "Merkel", "amam1234", clientIPAddressNA)).start();
			new Thread(new PlayerClientSignInThread(playerClientNA, "Hollande", "fhfh1234", clientIPAddressNA)).start();
			
			//sign in for AS server
			new Thread(new PlayerClientSignInThread(playerClientAS, "Clinton", "bcbc1234", clientIPAddressAS)).start();
			new Thread(new PlayerClientSignInThread(playerClientAS, "Bush", "gbgb1234", clientIPAddressAS)).start();
			new Thread(new PlayerClientSignInThread(playerClientAS, "Xi", "jxjx1234", clientIPAddressAS)).start();
			new Thread(new PlayerClientSignInThread(playerClientAS, "Merkel", "amam1234", clientIPAddressAS)).start();
			new Thread(new PlayerClientSignInThread(playerClientAS, "Hollande", "fhfh1234", clientIPAddressAS)).start();
			
			
			//sign out for EU server
			new Thread(new PlayerClientSignOutThread(playerClientEU, "Clinton", clientIPAddressEU)).start();
			new Thread(new PlayerClientSignOutThread(playerClientEU, "Bush", clientIPAddressEU)).start();
			new Thread(new PlayerClientSignOutThread(playerClientEU,"Xi", clientIPAddressEU)).start();
			new Thread(new PlayerClientSignOutThread(playerClientEU, "Merkel", clientIPAddressEU)).start();
			
			//sign OUT for NA server
			new Thread(new PlayerClientSignOutThread(playerClientNA, "Clinton", clientIPAddressNA)).start();
			new Thread(new PlayerClientSignOutThread(playerClientNA, "Bush", clientIPAddressNA)).start();
			new Thread(new PlayerClientSignOutThread(playerClientNA,"Xi", clientIPAddressNA)).start();
			new Thread(new PlayerClientSignOutThread(playerClientNA, "Merkel", clientIPAddressNA)).start();
			
			//sign out for AS server
			new Thread(new PlayerClientSignOutThread(playerClientAS, "Clinton", clientIPAddressAS)).start();
			new Thread(new PlayerClientSignOutThread(playerClientAS, "Bush", clientIPAddressAS)).start();
			new Thread(new PlayerClientSignOutThread(playerClientAS,"Xi", clientIPAddressAS)).start();
			new Thread(new PlayerClientSignOutThread(playerClientAS, "Merkel", clientIPAddressAS)).start();
			*/
			//account transfer
			new Thread(new PlayerClientAccountTransferThread(playerClientEU, "Clinton", "bcbc1234", clientIPAddressEU,clientIPAddressAS)).start();
			new Thread(new PlayerClientAccountTransferThread(playerClientEU, "ClintonEU", "bcbc1234", clientIPAddressEU,clientIPAddressAS)).start();
			new Thread(new PlayerClientAccountTransferThread(playerClientNA, "ClintonNA", "bcbc1234", clientIPAddressNA,clientIPAddressAS)).start();
			new Thread(new PlayerClientAccountTransferThread(playerClientEU, "BushEU", "gbgb1234", clientIPAddressEU,clientIPAddressNA)).start();
			
			
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}
